package com.spelet.UIUtils;

import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.spelet.Main;
import com.spelet.screens.Screen;

public class TransitionScreen extends Screen {

	private Main main;
	private Screen first, second;
	private ArrayList<TransitionEffect> effects;
	int currentTransitionEffect;
	
	public TransitionScreen(Main main, Screen first, Screen second,
			ArrayList<TransitionEffect> effects) {
		this.main = main;
		this.first = first; 
		this.second = second;
		this.effects = effects;
		currentTransitionEffect = 0;
	}

	@Override
	public boolean keyDown(int arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean keyTyped(char arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean keyUp(int arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean scrolled(int arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchDown(int arg0, int arg1, int arg2, int arg3) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchDragged(int arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchMoved(int arg0, int arg1) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchUp(int arg0, int arg1, int arg2, int arg3) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void update() {
		
	}

	@Override
	public void render() {
		if (currentTransitionEffect >= effects.size()) {
			main.activeScreen = second;
			main.activeScreen.render();
			second.enter();
			return;
		}

		effects.get(currentTransitionEffect).update(Gdx.graphics.getDeltaTime());
		
		if(currentTransitionEffect==0) {
			first.update();
			effects.get(currentTransitionEffect).render(first);
		} else {
			second.update();
			effects.get(currentTransitionEffect).render(second);
		}
		if (effects.get(currentTransitionEffect).isFinished())
			currentTransitionEffect++;
	}

	@Override
	public void enter() {
		// TODO Auto-generated method stub
		
	}
}
